
import random
from omega import geobox
from omega import playermanager
from omega import actionmanager
from omega import entitymanager

types = {0:'planet',
         1:'ship'}

subtypes = {0:'c',
            1:'m',
            2:'x',
            3:'destroyer',
            4:'cruiser',
            5:'battle'}

class Game(object):
    def __init__(self):
        self.turn = 0
        self.size = {'n':300,'e':400,'s':300,'w':400}
        self.geo = geobox.GeoBox()
        self.pm = playermanager.PlayerManager()
        self.am = actionmanager.ActionManager()
        self.em = entitymanager.EntityManager()
        
    def new_player(self,name=None):
        self.pm.
        
        
    def make_planets(self,amount):
        for i in range(0,amount):
            x = random.randint(self.west,self.east)
            y = random.randint(self.south,self.north)
            self.ents_count += 1
            id = self.ents_count
            # id,type,sub,owner,x,y
            planet = [id,0,1,0,x,y]
            self.ents[id] = planet
            self.planets.append(planet)
            
    def find_home(self):
        planet = [0,0,0,1,0,0];
        while planet[3] != 0:
            planet = random_planet(self)
        return planet
    
    def random_planet(self):
        idx = random.randint(0,len(self.planets))
        return self.planets[idx]
    
    def find_home(self):
        planet = [0,0,0,1,0,0];
        while planet[3] != 0:
            planet = random_planet(self)
        return planet
    
    def make_planets(self,amount):
        for i in range(0,amount):
            x = random.randint(self.west,self.east)
            y = random.randint(self.south,self.north)
            self.ents_count += 1
            id = self.ents_count
            # id,type,sub,owner,x,y
            planet = [id,0,1,0,x,y]
            self.ents[id] = planet
            self.planets.append(planet)
    
    def random_planet(self):
        idx = random.randint(0,len(self.planets))
        return self.planets[idx]
            